<template>
  <div>
    <h4>生产标签信息</h4>
      <el-form-item label="生产日期标题:" :label-width="formLabelWidth">
        <el-input
          v-model="info.printingAlias.productionDateName"
          size="small"
          style="width: 240px;"
          placeholder="例如：生产日期"
        ></el-input>
      </el-form-item>
      <el-form-item label="生产商标题:" :label-width="formLabelWidth">
        <el-input
          v-model="info.printingAlias.salesOrganizationName"
          size="small"
          style="width: 240px;"
          placeholder="例如：生产商"
        ></el-input>
      </el-form-item>
      <el-form-item label="标签显示【地址】:" :label-width="formLabelWidth">
        <el-input
          v-model="info.printingAlias.warehouseAddress"
          size="small"
          style="width: 240px;"
          placeholder="标签中显示生产商的【地址】"
        ></el-input>
      </el-form-item>
      <el-form-item label="许可证编码标题:" :label-width="formLabelWidth">
        <el-input
          v-model="info.printingAlias.licence"
          size="small"
          style="width: 240px;"
          placeholder="例如：食品生产许可证编号"
        ></el-input>
      </el-form-item>
      <el-form-item label="许可证编码:" :label-width="formLabelWidth">
        <el-input
          v-model="info.productionLicence"
          size="small"
          style="width: 240px;"
          placeholder="例如：SC12444060400576"
        ></el-input>
      </el-form-item>
      <el-form-item label="是否隐藏配料表:" :label-width="formLabelWidth">
        <el-switch v-model="info.printingHide.ingredient"></el-switch>
      </el-form-item>
      <el-form-item label="是否隐藏净含量:" :label-width="formLabelWidth">
        <el-switch v-model="info.printingHide.netContent"></el-switch>
      </el-form-item>
      <el-form-item label="是否隐藏许可证编码:" :label-width="formLabelWidth">
        <el-switch v-model="info.printingHide.licence"></el-switch>
      </el-form-item>
      <el-form-item label="是否隐藏产品执行标准:" :label-width="formLabelWidth">
        <el-switch v-model="info.printingHide.executiveStandards"></el-switch>
      </el-form-item>
      <el-form-item label="是否隐藏营养成分表:" :label-width="formLabelWidth">
        <el-switch v-model="info.printingHide.goodsSkuProductionNutrientsList"></el-switch>
      </el-form-item>

  </div>
</template>

<script>
export default {
  data() {
    return {
      formLabelWidth: "160px",
      info: {
        productionLicence: '',
        printingAlias: {
          productionDateName: '',
          salesOrganizationName: '',
          warehouseAddress: '',
          licence: '',
        },
        printingHide: {
          ingredient: false,
          netContent: false,
          licence: false,
          executiveStandards: false,
          goodsSkuProductionNutrientsList: false,
        }
      }
    };
  },
  methods: {
    init(warehouseFrom) {
      const printingAlias = JSON.parse(warehouseFrom.printingAlias || null)
      const printingHideList = JSON.parse(warehouseFrom.printingHide || null)
      const printingHideMap = {}
      if (printingHideList) {
        printingHideList.forEach(key => {
          printingHideMap[key] = true
        })
      }
      this.info = {
        productionLicence: warehouseFrom.productionLicence,
        printingAlias: printingAlias || {},
        printingHide: printingHideMap || {},
      }
    },
    getParams() {
      const params = {
        ...this.info
      }
      if (params.printingHide) {
        const hideKeys = Object.keys(params.printingHide).filter(key => params.printingHide[key])
        params.printingHide = hideKeys
      }
      return params
    }
  },
};
</script>
<style lang="scss" scoped>

</style>